]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dbusServices/extensions: Don't use getCurrentExtension()
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 9 Jul 2023 10:47:05 +0000 (12:47 +0200)
committerMarge Bot <marge-bot@gnome.org>
Sat, 15 Jul 2023 11:07:12 +0000 (11:07 +0000)
The prefs dialog is created on behalf of a particular extension.
It's a bit silly to rely on getCurrentExtension() to access it,
instead of just keeping track of it ourselves.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>

js/dbusServices/extensions/extensionPrefsDialog.js

index 404cbbeac3716a48aa8b0eac5fa5ee3478cafaf8..01c4a5c20e2f6b94f62f32ad12367f948b92d59e 100644 (file)
@@ -18,20 +18,24 @@ export const ExtensionPrefsDialog = GObject.registerClass({
             search_enabled: false,
         });
 
-        this._loadPrefs(extension).catch(e => {
+        this._extension = extension;
+
+        this._loadPrefs().catch(e => {
             this._showErrorPage(e);
             logError(e, 'Failed to open preferences');
         });
     }
 
-    async _loadPrefs(extension) {
+    async _loadPrefs() {
         // give extension prefs access to their own extension object
-        ExtensionUtils.setCurrentExtension(extension);
+        ExtensionUtils.setCurrentExtension(this._extension);
+
+        const {dir, metadata} = this._extension;
 
-        const prefsJs = extension.dir.get_child('prefs.js');
+        const prefsJs = dir.get_child('prefs.js');
         const prefsModule = await import(prefsJs.get_uri());
 
-        const prefsObj = new prefsModule.default(extension.metadata);
+        const prefsObj = new prefsModule.default(metadata);
         prefsObj.fillPreferencesWindow(this);
 
         if (!this.visible_page)
@@ -56,8 +60,7 @@ export const ExtensionPrefsDialog = GObject.registerClass({
         while (this.visible_page)
             this.remove(this.visible_page);
 
-        const extension = ExtensionUtils.getCurrentExtension();
-        this.add(new ExtensionPrefsErrorPage(extension, e));
+        this.add(new ExtensionPrefsErrorPage(this._extension, e));
     }
 });